package cn.lbl.face2025;

import java.util.Arrays;

public class 移除元素 {

    public static int removeElement(int[] nums, int val) {
        int k = 0;
        int[] array = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            array = Arrays.stream(nums).filter(num -> num != val).toArray();
        }
        System.out.println(Arrays.toString(array));
        return array.length;
    }

    public static void main(String[] args) {
        int[] nums = {0,1,2,2,3,0,4,2};
        System.out.println(removeElement(nums,2));
    }
}
